home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Textdisplayers / JMore / Source / jctype.h next >
C/C++ Source or Header  |  1996-09-26  |  4KB  |  108 lines

  1. /*
  2.  *    jctype.h
  3.  *    for kanji character handling
  4.  */
  5.  
  6. #ifndef    _JCTYPE_H_
  7. #define    _JCTYPE_H_
  8.  
  9. #include    <ctype.h>
  10.  
  11. #define    J_KPUN    0x1    /* punctuation character for JIS kana */
  12. #define    J_KANA    0x2    /* JIS kana charactor */
  13. #define    J_KNJ1    0x4    /* 1st charactor in ms-kanji code */
  14. #define    J_KNJ2    0x8    /* 2st charactor in ms-kanji code */
  15.  
  16. extern    const    char    _jctype[];
  17.  
  18. #define    iskana(c)    ((_jctype + 1)[(c)&0xff]&(J_KANA|J_KPUN))
  19. #define    iskmoji(c)    ((_jctype + 1)[(c)&0xff]&J_KANA)
  20. #define    iskanapn(c)    ((_jctype + 1)[(c)&0xff]&J_KPUN)
  21. #define    iskalpha(c)    ((isascii(c) && isalpha(c)) || iskmoji(c))
  22. #define    iskalnum(c)    ((isascii(c) && isalnum(c)) || iskmoji(c))
  23. #define    iskprint(c)    ((isascii(c) && isprint(c)) || iskana(c))
  24. #define    iskgraph(c)    ((isascii(c) && isgraph(c)) || iskana(c))
  25. #define    iskpunct(c)    ((isascii(c) && ispunct(c)) || iskanapn(c))
  26. #define    iskpun    iskanapn    /* same as LSI-C 86 with MS-DOS */
  27. #define    isalkana    iskalpha    /* same as LSI-C 86 with MS-DOS */
  28. #define    isalnmkana    iskalnum    /* same as LSI-C 86 with MS-DOS */
  29. #define    isprkana    iskprint    /* same as LSI-C 86 with MS-DOS */
  30. #define    isgrkana    iskgraph    /* same as LSI-C 86 with MS-DOS */
  31. #define    ispnkana    iskpunct    /* same as LSI-C 86 with MS-DOS */
  32.  
  33. #define    ismsknj(c)    ((_jctype + 1)[(c)&0xff]&J_KNJ1)
  34. #define    ismsknj2(c)    ((_jctype + 1)[(c)&0xff]&J_KNJ2)
  35. #define    iskanji    ismsknj    /* same as LSI C-86 with MS-DOS */
  36. #define    iskanji2    ismsknj2    /* same as LSI C-86 with MS-DOS */
  37.  
  38. int    chkmsctype(char, int);
  39. int    nthmsctype(const char *, int);
  40. #define    chkctype    chkmsctype    /* same as LSI C-86 with MS-DOS */
  41. #define    nthctype    nthmsctype    /* same as LSI C-86 with MS-DOS */
  42.  
  43. #define    CT_ILGL    (-1)
  44. #define    CT_ANK    0
  45. #define    CT_KJ1    1
  46. #define    CT_KJ2    2
  47.  
  48. unsigned    short    mstojis(unsigned short);
  49. unsigned    short    jistoms(unsigned short);
  50. #define    jmstojis    mstojis
  51. #define    jistojms    jistoms
  52.  
  53. #ifndef    BOOL
  54. #define    BOOL    short
  55. #endif
  56. BOOL    msknj(unsigned short);    /* ms-kanji code, or not */
  57. #define    msknj0(c)    (msknj(c) && (c) <= 0x889e)    /* symbol, ANK, etc... */
  58. /* kanji 1st Level */
  59. #define    msknj1(c)    (msknj(c) && 0x889f <= (c) && (c) <= 0x9872)
  60. /* kanji 2nd Level */
  61. #define    msknj2(c)    (msknj(c) && 0x989f <= (c) && (c) <= 0xea9e)
  62. #define    jiszen    msknj    /* same as LSI C-86 with MS-DOS */
  63. #define    jisl0    msknj0    /* same as LSI C-86 with MS-DOS */
  64. #define    jisl1    msknj1    /* same as LSI C-86 with MS-DOS */
  65. #define    jisl2    msknj2    /* same as LSI C-86 with MS-DOS */
  66.  
  67. #define    ismsupper(c)    (0x8260 <= (c) && (c) <= 0x8279)
  68. #define    ismslower(c)    (0x8281 <= (c) && (c) <= 0x829a)
  69. #define    ismsalpha(c)    (ismsupper(c) || ismslower(c))
  70. #define    ismsdigit(c)    (0x824f <= (c) && (c) <= 0x8258)
  71. #define    ismskata(c)    (0x8340 <= (c) && (c) <= 0x8396 && (c) != 0x837f)
  72. #define    ismshira(c)    (0x829f <= (c) && (c) <= 0x82f1)
  73. #define    ismssymbol(c)    (0x8141 <= (c) && (c) <= 0x81ac && (c) != 0x817f)
  74. #define    ismsspace(c)    ((c) == 0x8140)
  75. #define    jisupper    ismsupper    /* same as LSI C-86 with MS-DOS */
  76. #define    jislower    ismslower    /* same as LSI C-86 with MS-DOS */
  77. #define    jisdigit    ismsdigit    /* same as LSI C-86 with MS-DOS */
  78. #define    jiskata    ismskata    /* same as LSI C-86 with MS-DOS */
  79. #define    jishira    ismshira    /* same as LSI C-86 with MS-DOS */
  80. #define    jiskigou    ismssymbol    /* same as LSI C-86 with MS-DOS */
  81. #define    jisspace    ismsspace    /* same as LSI C-86 with MS-DOS */
  82.  
  83. typedef    unsigned short    u_short;
  84. extern    const    u_short    _jascii[];
  85. extern    const    char    _jsymbol[];
  86.  
  87. #define    isjupper(c)    (0x2341 <= (c) && (c) <= 0x235a)
  88. #define    isjlower(c)    (0x2361 <= (c) && (c) <= 0x237a)
  89. #define    isjalpha(c)    (isjupper(c) || isjlower(c))
  90. #define    isjdigit(c)    (0x2330 <= (c) && (c) <= 0x2339)
  91. #define    isjalnum(c)    (isjalpha(c) || isjdigit(c))
  92. #define    isjkata(c)    (0x2521 <= (c) && (c) <= 0x2576)
  93. #define    isjhira(c)    (0x2421 <= (c) && (c) <= 0x2473)
  94. #define    isjsymbol(c)    ((0x2122 <= (c) && (c) <= 0x217e) || \
  95.             (0x2221 <= (c) && (c) <= 0x222e))
  96. #define    isjspace(c)    ((c) == 0x2121)
  97. #define    tojlower(c)    ((isjupper(c)) ? (c) + ' ' : 0)
  98. #define    tojupper(c)    ((isjlower(c)) ? (c) - ' ' : 0)
  99. #define    tojhira(c)    ((isjkata(c)) ? (c) - 0x100 : 0)
  100. #define    tojkata(c)    ((isjhira(c)) ? (c) + 0x100 : 0)
  101.  
  102. #define    jistoascii(c)    ((isjalnum(c)) ? \
  103.             (c)&0xff : (((((c)>>CHAR_BIT)&0xff) == '!') ? \
  104.             (_jsymbol + 1)[(c)&0x7f] : 0))
  105. #define    asciitojis(c)    ((_jascii + 1)[(c)&0x7f])
  106.  
  107. #endif    /* _JCTYPE_H_ */
  108.